<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>提示</title>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="format-detection" content="email=no">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <script>window.injectInfo = { appName: "cmspromo-fallback", env: "PROD" };</script>
    <script>window.publicPath = window.__basement_public_path__ = "https://gw.alipayobjects.com/render/p/yuyan/180020010001201259/";</script>
    <script src="https://appx/web-view.min.js"></script>
    <style>
        *,
        *:before,
        *:after {
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            box-sizing: border-box
        }

        *:focus {
            outline: none
        }

        body,
        p,
        img,
        div,
        a,
        header {
            margin: 0;
            padding: 0
        }

        body,
        html {
            min-height: 100%
        }

        a,
        img {
            -webkit-touch-callout: none
        }

        a {
            text-decoration: none;
            color: #00aaee;
        }

        body {
            -webkit-user-select: none;
            user-select: none;
            color: #333;
            background: #f5f5f9;
            font-size: 14px;
            font-family: "Helvetica Neue", Helvetica, STHeiTi, sans-serif
        }

        header {
            text-align: center;
            margin-top: 75px;
            height: 96px
        }

        header img {
            width: 96px
        }

        p {
            text-align: center;
            padding: 20px 15px;
            font-size: 16px;
            line-height: 22px;
            color: #999
        }

        .btn {
            display: block;
            height: 42px;
            line-height: 42px;
            font-size: 20px;
            color: #fff;
            background: #3ea3fe;
            border-radius: 4px
        }
    </style>
</head>

<body>
    <header>
        <img
            src="">
    </header>
    <p>您即将跳转至其他应用或网站，<br>请勿随意打开不明来源链接</p>
    <p><a href="javascript:;" class="btn" id="J-redirectBtn">点击跳转</a></p>
    <p><a href="javascript:;" class="btn" id="J-redirectBtn2">点击跳转2</a></p>
    <script type="text/javascript">


        document.getElementById('J-redirectBtn2').addEventListener('click', function () {
            alert(1)
            window.location.href = 'xmcxzCus://'
        })



        function bridgeReady() {
            var query = new URLSearchParams(window.location.search);
            var url = query.get('url');
            var redirectBtn = document.getElementById('J-redirectBtn');

            redirectBtn && redirectBtn.addEventListener('click', function () {
                fetch('https://basement-api.alipay.com/cmspromo/check?url=' + url).then((res) => {
                    return res.json();
                }).then((res) => {
                    alert('success')
                    if (res && res.success) {
                        alert('success1')
                        AlipayJSBridge.call('openInBrowser', {
                            url: decodeURIComponent(url),
                        }, function (rst) {
                            alert(rst)
                        });
                        // AlipayJSBridge.call('closeWebview');
                    } else {
                        alert('success fail')
                        AlipayJSBridge.call('alert', {
                            message: '链接存在风险，已为您拦截',
                            button: '立即关闭'
                        }, function () {
                            // AlipayJSBridge.call('closeWebview');
                        });
                    }
                }).catch(() => {
                    alert('调用失败，直接打开链接')
                    // 调用失败，直接打开链接
                    AlipayJSBridge.call('openInBrowser', {
                        url: decodeURIComponent(url),
                    }, function (rst) {
                        alert(JSON.stringify(rst))
                    });
                    // AlipayJSBridge.call('closeWebview');
                });
            }, false);
        }
        window.AlipayJSBridge ? bridgeReady() : document.addEventListener('AlipayJSBridgeReady', bridgeReady);
    </script>


</body>

</html>
